package com.htrq.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.htrq.entity.ICKgs;
import com.htrq.entity.Page;
import com.htrq.service.ICardgsService;
import com.htrq.util.ExportToExcelUtil;

@Controller
@RequestMapping("jsp/basinfo")
public class ICardGsController {
	
	@Resource
	private ICardgsService gsService;
	
	@RequestMapping("getAllgs")
	public String getAllgs(ICKgs gs,Page page, HttpServletResponse response) throws IOException, ParseException{
		List<ICKgs> list=gsService.getAllgs(gs,page);
		String str=JSON.toJSONString(list);
		Long total=gsService.getTotal(gs);
		String json="{total:"+total+",jhs:"+str+"}";
		response.setContentType("text/html;charset=utf8");
		PrintWriter out =response.getWriter();
		out.write(json);
		return null;
	}
	
	@RequestMapping("exportgs")
	public String exportgs(ICKgs gs,HttpServletRequest request,HttpServletResponse response)throws Exception{
		String titles[]={"挂失卡号","挂失站点","挂失时间","操作员","挂失状态"};
		List<Object[]> list=gsService.exportbyForm(gs);
		ExportToExcelUtil.exportToExcel(request,response,"卡挂失查询导出结果.xls", "记录", titles, list);
		return null;
	}
}
